// Sequence.java // access Postgresql sequence generators package dwarf; import dwarf.Database; import dwarf.DbRowSet; public class Sequence { public static int next(String sequenceName) { long val = 0; DbRowSet res = null; try { res = Database.RunSql("select nextval('" + sequenceName + "')"); } catch (java.sql.SQLException e){ // hack throw new RuntimeException("SQL Failure: " + e.getMessage()); } while(res.next()){ val = res.getLong("nextval"); } if(val == 0){ // hack throw new RuntimeException("Postgresql sequence " + sequenceName + " failed"); } return (int)val; } }